package com.af.monitorModule.common;

import com.alibaba.fastjson.JSONObject;

/**
 * @author lyz
 * @ClassName ResultEnum
 **/
public enum ResultEnum{

    UNKOWN_ERROR(-1, "未知错误"),
    OK(200, "成功"),

    WILL_RUN_NOW(200, "立即执行设置成功，下次获取将会执行"),
    CANT_RUN_NOW(10010, "立即执行和自动执行的时间太近了，耐心等待一会吧"),

    USER_PASSWORD_DECORRECT(20004, "密码错误"),

    ROLE_ISNOT_EXIST(10002, "角色不存在！"),
    USER_ISNOT_EXIST(20002, "用户不存在！"),
    COMPANY_ISNOT_EXIST(20004, "客户不存在！"),
    STATE_ERROR(20003, "状态错误！"),
    VERSION_NO_CORRESPONDING(20007, "数据已经在其他地方修改！"),

    PARAM_INCORRECRT(20008, "参数异常！"),
    HEART_ERROR(10003, "心跳失败！"),

    ASYNC_CHECK_ERROR(10004, "并行检测错误！"),
    DATA_ISNOT_EXIST(10007, "数据不存在！"),
    TASK_IS_REPEAT(10008, "任务已经存在！"),

    CREATE_ERROR(20011, "创建错误"),

    ;

    private final Integer code;
    private final String msg;

    ResultEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public JSONObject getResult(){
        JSONObject res = new JSONObject();
        res.put("code",code);
        res.put("msg",msg);
        return res;
    }

    public JSONObject putData(Object data){
        JSONObject res = new JSONObject();
        res.put("code",code);
        res.put("msg",msg);
        res.put("data",data);
        return res;
    }
}
